
<script>
import i18n from '@/locale'
export default {
  name: 'Dyndate',
  model: {
    prop: 'name',
    event: 'input'
  },
  props: {
    name: {
      type: [Array, Object, String, Number],
      default: ''
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handlerSelect(value) {
      this.$emit('input', value)
      // 执行事件对象
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      <el-date-picker
        clearable={this.item.clearable}
        value={this.name}
        on-input={this.handlerSelect.bind(this)}
        type={this.item.datatype ? this.item.datatype : 'date'}
        disabled={this.item.disabled}
        value-format={this.item.dataformat ? this.item.dataformat : 'yyyy-MM-dd'}
        format={this.item.dataformat ? this.item.dataformat : 'yyyy-MM-dd'}
        placeholder={ `${i18n.t('pleaseSelect')}${this.item.label}`}>
      </el-date-picker>
    )
  }
}
</script>
<style scoped lang="scss">
@import "~@/assets/styles/defaultStyle.scss";
</style>
